package com.zerui.manager.icc.properties;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.net.URL;

@Setter
@Getter
@ConfigurationProperties(prefix = "icc")
public class ICCProperties {
    private Boolean enable;
    private String protocol;
    private String host;
    private Integer port;
    private String clientId;
    private String clientSecret;
    private String callbackEndpoint;
    /**
     * 部门管理接口地址
     */
    private ICCDeptProperties depart;
    /**
     * 人员管理接口地址
     */
    private ICCPersonProperties person;
    /**
     * 车辆信息管理接口
     */
    private ICCCarProperties car;
    /**
     * 卡片信息管理接口
     */
    private ICCCardProperties card;
    /**
     * 设备信息管理接口
     */
    private ICCApiProperties device;
    /**
     * 门禁授权
     */
    private ICCAccessControlProperties accessControl;

    public String getCallbackClientId() throws Exception {
        URL url = new URL(this.callbackEndpoint);
        return url.getHost() + "_" + url.getPort();
    }

    public String getUrl() {
        return protocol + "://" + host + ":" + port;
    }

}
